﻿

var par = {
    init: function ($scope, $http) {
        $http.get("/Home/Getuser").success(function (response) {
            $scope.Users = response;
        });
        $scope.orderBy = "Id";
    },
    login: function ($scope, $http) {
        $http({
            url: "/Home/Login",
            method: "post",
            data: $('#login').serialize(),
            headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
        }).success(function(data) {
            if (data.Result) {
                window.location.href = "Home/userlist";
            } else {
                $scope.data = data;
            }
        }).error(function(error) {
            alert(error);
        });

    },
    model: angular.module('myapp', []),
};

par.model.controller('myctl', function ($scope, $http) {

    $scope.Login = function () {
        par.login($scope, $http);

    };

});
